using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;

namespace System.ServiceProcess
{
    /// <summary>
    /// The Host installer
    /// </summary>
    public partial class ProjectInstallerHelper : Installer
    {
        /// <summary>
        /// The service name
        /// </summary>
        String m_serviceName = "";

        /// <summary>
        /// Default constructor :
        /// </summary>
        /// <param name="serviceName">selected service name</param>
        public ProjectInstallerHelper(String serviceName)
        {
            //enreg
            m_serviceName = serviceName;

            //Sarting installation sequence
            InitializeComponent();

            //finishing installation :
            this.svcMonServiceInstaller.DisplayName = m_serviceName;
            this.svcMonServiceInstaller.ServiceName = m_serviceName;

        }

        private void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)
        {
#if DEBUG
            string result = "";
            try
            {
                ServiceController svc =
                    new ServiceController(m_serviceName);
                svc.Start();
                result = svc.Status.ToString();
            }
            catch (Exception ex)
            {
                result = "FAILED\r\n" + ex.Message;
                throw;
            }
            finally
            {

                global::System.Windows.Forms.MessageBox.Show("\t(Debug only) Installation Result of '"
                    + m_serviceName + "'\r\n\t" + result);
            }
#endif
        }
    }
}